package eu.reply.android.flashm;
import java.util.ArrayList;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class FlashMapOverlay extends ItemizedOverlay {
	private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
	private Context mContext;
	
	public FlashMapOverlay(Drawable defaultMarker) {
		  super(boundCenterBottom(defaultMarker));	
		// TODO Auto-generated constructor stub
	}


    public FlashMapOverlay(Drawable defaultMarker, Context context) {
      super(defaultMarker);
      mContext = context;
    }
    
    
	@Override
	protected OverlayItem createItem(int i) {
	  return mOverlays.get(i);
	}

	@Override
	public int size() {
	  return mOverlays.size();
	}

	@Override
	protected boolean onTap(int index) {
	    OverlayItem item = mOverlays.get(index);
	    AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
	    dialog.setTitle(item.getTitle());
	    dialog.setMessage(item.getSnippet());
//	    dialog.setPositiveButton("Yes", new OnClickListener() {
//	       
//	        @Override
//	        public void onClick(DialogInterface dialog, int which) {
//	            dialog.dismiss();
//	        }
//	    });
	    dialog.show();
	    return true;
	}
	
	public void addOverlay(OverlayItem overlay) {
        mOverlays.add(overlay);
        populate();
    }

}
